package com.chb.dmp.utils

import java.io.{FileInputStream, FileReader, InputStream}
import java.util.Properties

import org.apache.spark.sql.{Dataset, SparkSession}


class SparkConfigHelper(builder: SparkSession.Builder) {
  def loadConfig(): SparkSession.Builder = {
    // builder.config(...)
    builder.config("spark.app.name", "SparkName")

    builder
  }

}

object SparkConfigHelper {
  /**
   * 为SparkSession添加一个方法
   * 使用隐式转换 将SparkSession -> SparkConfigHelper
   */
  implicit def sparkToHelper(builder: SparkSession.Builder): SparkConfigHelper = {
    new SparkConfigHelper(builder)
  }

  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder()
      .appName("test")
      .master("local[*]")
      .loadConfig()
      .getOrCreate()


  }
}
